#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>

/* This connects to the Maestro */
int maestro_connect();

/* This disconnects from the Maestro */
int maestro_disconnect(int fd);


/* This command sets the target position for a given channel.
   The position is in ms length pulse, and 1500ms is usually
   approximately neutral. */
int setTarget(int fd, int channel, unsigned int microsecPos);


/* This command sets the speed at which the servo transitions
   from one target to another. The rate is in 0.25uS/10ms, so
   a rate of 1 would mean the servo would take 40 seconds to 
   transition from the pose at 1ms to the pose 2ms. */
int setSpeed(int fd, int channel, int rate);


/* This limits the acceleration in units of 0.25uS/10ms/80ms.
   A setting of 1 would mean the servo output takes 3 seconds
   to move smoothly from 1ms to 2ms. Note, this also ramps
   the speed down upon approaching the target. */
int setAccel(int fd, int channel, int rate);


// Returns commanded servo position
int getPosition(int fd, int channel);


// Returns 0x00 if no servos moving, 0x01 if any are moving
int getMovingState(int fd);


// Returns error bits
int getErrors(int fd);


